package com.jin.六大设计原则.迪米特法则.顺从;

import java.util.ArrayList;
import java.util.List;

public class Teacher {
    private String name;
    private String clazz;
    private static List<Student> studentList;

    public Teacher() {
    }

    public Teacher(String name, String clazz) {
        this.name = name;
        this.clazz = clazz;
    }

    //在类加载的时候初始化
    static {
         studentList = new ArrayList<>();
         studentList.add(new Student("小明",10,589));
         studentList.add(new Student("小刚",54,356));
         studentList.add(new Student("小红",23,439));
         studentList.add(new Student("小靳",2,665));
         studentList.add(new Student("小李",19,502));
    }


    //老师来管理学生
    //总分
    public double clazzTotalScore(){
        double totalScore = 0;
        for (Student student : studentList) {
            totalScore=totalScore+student.getGrade();
        }
        return totalScore;
    }

    //平均分
    public double clazzAverageScore(){
        double totalScore = 0;

        for (Student student : studentList) {
            totalScore=totalScore+student.getGrade();
        }
        return totalScore/ studentList.size();
    }

    //班级人数
    public int clazzStudentCount(){
        return studentList.size();
    }

    //静态方法
//    public static List<Student>getStudentList(){
//        return studentList;
//    }

    public String getName() {
        return name;
    }

    public String getClazz() {
        return clazz;
    }

//    String a = test();
//
//    public String test(){
//        return "000";
//    }
}
